package demo;
import java.util.*;

/*
 * public class demo.TreeNode {
 *   int val = 0;
 *   demo.TreeNode left = null;
 *   demo.TreeNode right = null;
 *   public demo.TreeNode(int val) {
 *     this.val = val;
 *   }
 * }
 */

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param root TreeNode类 the root of binary tree
     * @return int整型二维数组
     */
    List<Integer> list1=new ArrayList<>();
    List<Integer> list2=new ArrayList<>();
    List<Integer> list3=new ArrayList<>();

    public int[][] threeOrders (TreeNode root) {
        // write code here
        traveler(root);
        int[][] arr=new int[3][list1.size()] ;

        for(int i=0;i<arr[0].length;i++ ){

            arr[0][i]=list1.get(i);
            arr[1][i]=list2.get(i);
            arr[2][i]=list3.get(i);
        }
        return arr;
    }
    public  void traveler(TreeNode root){
        if(root == null){
            return ;
        }
        list1.add(root.val);
        traveler(root.left);
        list2.add(root.val);
        traveler(root.right);
        list3.add(root.val);
    }
}